<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <base href="${APP_PATH}/">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
    <title>教学管理系统</title>
    <link rel="icon" href="public/favicon.ico" type="image/ico">
    <%@include file="/commons.jsp" %>
</head>

<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <%@ include file="/menu.jsp" %>
        <!--End 左侧导航-->
        <!--头部信息-->
        <%@ include file="/head.jsp" %>
        <!--End 头部信息-->
        <!--页面主要内容-->
        <main class="lyear-layout-content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="card-body">
                                <form class="row" id="updateForm">
                                    <input type="hidden" name="rid" value="${role.rid}">
                                    <div class="form-group col-md-12">
                                        <div class="form-group col-md-12">
                                            <label for="rname">名字</label>
                                            <input type="text" class="form-control" id="rname" name="rname" value="${role.rname}" placeholder="请输入角色名"/>
                                        </div>
                                        <div class="form-group col-md-12">
                                            <button type="button" class="btn btn-primary" id="updateBtn">修 改</button>
                                            <button type="button" class="btn btn-default" onclick="javascript:history.back(-1);return false;">返 回</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
        <!--End 页面主要内容-->
    </div>
</div>
<script type="text/javascript">
    $(function () {
        layer.msg("加载中", {time: 200, icon: 16, shift: 5}, function () {
            $("#updateBtn").click(function () {
                // Todo 前端校验
                $.ajax({
                    url: "manage/role/updateDo",
                    data: $("#addForm").serialize(),
                    type: "post",
                    success: function (obj) {
                        if (obj.result) {
                            layer.msg("修改角色成功", {time: 1000, icon: 6, shift: 6}, function () {
                                location.href = "manage/role/index"
                            })
                        } else {
                            layer.msg("修改角色失败", {time: 1000, icon: 5, shift: 6}, function () {
                            })
                        }
                    }
                })
            })
        });//layer
    });//入口
</script>
</body>
</html>
